/*
 * trdp_mini_vos.h
 *
 *  Created on: 2016年12月20日
 *      Author: think
 */

#ifndef INC_TRDP_MINI_VOS_H_
#define INC_TRDP_MINI_VOS_H_

#include "../config/trdp_mini_config.h"
#include "../api/trdp_mini_types.h"

#ifdef __cplusplus
extern "C" {
#endif

#define INITFCS         0xffffffff      /**< Initial FCS value */
#define SIZE_OF_FCS     4               /**< for better understanding of address calculations */

extern INT8U	gIsRedPortActive;
extern INT32U   gLocolTopoCnt;

/** Compute crc32 according to IEEE802.3. input crc param is the initialize crc value which usually should be set to INITFCS = 0xffffffff */
INT32U vos_crc32 (INT32U crc, const INT8U *pData, INT32U dataLen);
/*memory semaphore take*/
INT8U	vos_MemSemaphoreTake(void);
/*memory semaphore give*/
void	vos_MemSemaphoreGive(void);
/*package control block semaphore take*/
INT8U	vos_PcbSemaphoreTake(void);
/*package control block semaphore give*/
void	vos_PcbSemaphoreGive(void);
/*get MD package session ID*/
INT8U vos_getSessionID(INT8U *pSessionID, INT32U qIdx);

/*----------------------------UDP and TCP communication interface-------------------------------*/
INT8U vos_sendTCPMessage(INT8U *pSrcIP, INT8U *pDestIP, INT16U port, INT8U *pData, INT32U dataSize);
INT8U vos_sendUDPBroadcast(INT8U *pSrcIP, INT8U *pDestIP, INT16U port, INT8U *pData, INT32U dataSize);
INT8U vos_sendUDPMulticast(INT8U *pSrcIP, INT8U *pDestIP, INT16U port, INT8U *pData, INT32U dataSize);
INT8U vos_sendUDPUnicast(INT8U *pSrcIP, INT8U *pDestIP, INT16U port, INT8U *pData, INT32U dataSize);
//abort MD TCP Connection
INT8U	vos_abortTCPConnection(INT8U *pSrcIP, INT8U *pDestIP);

/*
 * user should complete the receive data function and call the trdp_mini_Receive_CallBack function to pass
 * the receive data to trdp_mini stack!!!!
 * */

#ifdef __cplusplus
}
#endif

#endif /* INC_TRDP_MINI_VOS_H_ */
